﻿using System;
using BizElements.BusinessLayer;

namespace BizElements.BusinessLayer.Aspects
{
    #region Documentation.
    /// <summary>
    /// Contains configuration for logging aspect.
    /// </summary>
    /// <remarks>Settings are read from the application's config file. The following are the default settings:
    /// <code>
    /// <configuration>
    ///     <appSettings>
    ///         <add key="BizElements.BusinessLayer.Aspects.LogAspectConfiguration.DetailProvider.Assembly" value="BizElements.BusinessLayer.Aspects" />
    ///         <add key="BizElements.BusinessLayer.Aspects.LogAspectConfiguration.DetailProvider.Class" value="BizElements.BusinessLayer.Aspects.LogDetailProvider"/>
    ///     </appSettings>
    /// </configuration>
    /// </code>
    /// </remarks>
    #endregion
    public static class LogAspectConfiguration
    {
        #region Configuration.

        /// <summary>
        /// Gets <see cref="ILogDetailProvider"/> used by attributes dealing with logging aspect.
        /// </summary>
        public static ILogDetailProvider DetailProvider { get; private set; }

        static LogAspectConfiguration()
        {
            DetailProvider = ReflectionUtil.TryCreateInstanceFromAppSettings("BizElements.BusinessLayer.Aspects.LogAspectConfiguration.DetailProvider.Assembly", "BizElements.BusinessLayer.Aspects.LogAspectConfiguration.DetailProvider.Class") as ILogDetailProvider;
            if (DetailProvider == null)
                DetailProvider = ReflectionUtil.TryCreateInstance("BizElements.BusinessLayer.Aspects", "BizElements.BusinessLayer.Aspects.LogDetailProvider") as ILogDetailProvider;
        }

        #endregion
    }
}